package com.congwulin.wechat.configuration;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicRabbitConfig {
    final static String queue_first = "topic.first";
    final static String queue_second = "topic.second";

    @Bean
    public Queue queue_first(){
        return new Queue(queue_first);
    }

    @Bean
    public Queue queue_second(){
        return new Queue(queue_second);
    }

    @Bean
    TopicExchange exchange(){
        return new TopicExchange("exchange");
    }

    @Bean
    Binding bingingExchangeForFirst(){
        return BindingBuilder.bind(queue_first()).to(exchange()).with("topic.first");
    }

    @Bean
    Binding bingingExchangeForSecond(){
        return BindingBuilder.bind(queue_second()).to(exchange()).with("topic.#");
    }
}
